package cn.edu.scau.cmi.huangmaoqin.FactoryMethod;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;
import cn.edu.scau.cmi.huangmaoqin.simpleFactoryMethod.Meat;
import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

public class GUIController {
	@FXML
	private TextField input;
	@FXML
	private TextArea showText;
	@FXML
	private Button ok;

	// Event Listener on TextField[#input].onAction
	@FXML
	public void Event_Enter(ActionEvent event) {
		String meatType = input.getText();
		MeatFactory meatFactory = null;
		switch (meatType) {
		case "beef":
			meatFactory = new BeefMeatFactory();
			break;
		case "pork":
			meatFactory = new PorkMeatFactory();
			break;
		case "chicken":
			meatFactory = new ChickenMeatFactory();
			break;
		default:
			showText.appendText("incorrect input!!!\n");
		}
		if (meatFactory != null) {
			Meat meat = meatFactory.getMeat();
			showText.appendText(meat.Cook()+"\n");
		}
	}
}
